function setTimeDateFmt (s) { // 个位数补齐十位数
  return s < 10 ? '0' + s : s
}

export default function createordernum (getDate) {
  const now = new Date()
  const year = now.getFullYear()
  let month = now.getMonth() + 1
  let day = now.getDate()
  let hour = now.getHours()
  let minutes = now.getMinutes()
  let seconds = now.getSeconds()
  month = setTimeDateFmt(month)
  day = setTimeDateFmt(day)
  hour = setTimeDateFmt(hour)
  minutes = setTimeDateFmt(minutes)
  seconds = setTimeDateFmt(seconds)
  if (getDate) {
    const data = year.toString() + '-' + month.toString() + '-' + day + ' ' + hour + ':' + minutes + ':' + seconds
    return data
  }
  const orderCode = year.toString() + month.toString() + day + hour + minutes + seconds
  return orderCode
  // 基于年月日时分秒+随机数生成订单编号
}
